<%@ page pageEncoding="UTF-8"%>
<%@ include file="/common/common.jsp"%>
<%
	//获取所有科室
	List<Map> deptList = QBuilder.db("basedb").queryHql("select new map(id as id , name as name ) from his_dept where sfyy = 1 ");
	Map<String,String> deptMap = new HashMap<String,String>();
	//科室放到map中 key-value(id-name)
	for(Map map : deptList){
		deptMap.put(map.get("id").toString(),map.get("name").toString());
	}
	
	//获取排版信息--用于生成到线上的数据
	SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
	String date = sdf.format(new Date());
	List<Map> list = QBuilder.db("basedb").queryHql("select distinct new map(a.zzlx as zzlx ,a.zxrq as zxrq ,b.pbkmmc as pbkmmc ,b.pbkmlx as pbkmlx,a.zlfmc as zlfmc ,c.xmdj as xmdj ,d.ks_id as ks_id ,d.ks_mc as ks_mc,a.kssj as kssj,b.yybm as yybm) from yy_schedule a , yy_pbzb b , YY_SFXXMK c ,YY_ZGBMK d  where a.pbzbid = b.pbzbid and a.zlfdm = c.id and a.jlzt = 0 and b.pbkm = d.id and a.zxrq>'"+date+"'  ");
	for(Map map : list){
		String id = Tools.getDesc(map.get("ks_id"),"");
		map.put("ks_mc",deptMap.get(id));
	}
	
	List list2 = QBuilder.db("basedb").queryHql("select distinct new map(a.zzlx as zzlx ,a.zxrq as zxrq ,b.pbkmmc as pbkmmc ,b.pbkmlx as pbkmlx,a.zlfmc as zlfmc ,c.xmdj as xmdj ,a.kssj as kssj,b.yybm as yybm) from yy_schedule a , yy_pbzb b , YY_SFXXMK c ,his_dept d  where a.pbzbid = b.pbzbid and a.zlfdm = c.id and a.jlzt = 0 and b.pbkm = d.id  and a.zxrq>'"+date+"'   ");
	list.addAll(list2);
	
	Message msg = new Message();
	msg.put("errcode",0);
	msg.put("data",list);
	msg.put("count",list.size());
	out.println(msg);
%>